package com.licenta.fbApp.client;

import com.licenta.fbApp.client.AppEventBus;
import com.licenta.fbApp.client.DisplayUserInfo;
import com.licenta.fbApp.client.FriendClickedEvent;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.datepicker.client.DatePicker;

public class LeftPanel extends Composite {
  public static final String LOGO_URL = "img/1.jpg";

  /**
 * @uml.property  name="panel"
 * @uml.associationEnd  multiplicity="(1 1)"
 */
final VerticalPanel panel = new VerticalPanel();

  public LeftPanel(Long uid) {
    initWidget(panel);
    addStyleName("leftPanel");

    final Image logo = new Image(LOGO_URL);
    logo.setStylePrimaryName("logoStyle");
    logo.addClickHandler(new ClickHandler() {

      
      public void onClick(ClickEvent event) {
        // when logo clicked, go to home page
        AppEventBus.getEventBus().fireEvent(
          new FriendClickedEvent(DisplayUserInfo.getUid(), true));
      }
    });
    final DatePicker dp = new DatePicker();

    // will auto-resize
    panel.setHeight("0px");
    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    // logo
    panel.add(logo);

    // final Image userImage = new Image();
    final VerticalPanel userInfoPanel = new VerticalPanel();
    userInfoPanel.add(new DisplayUserInfo.UserPic(uid));
    userInfoPanel.add(new DisplayUserInfo.UserName(uid));
    // user info
    panel.add(userInfoPanel);

    if (DisplayUserInfo.isMyself(uid)) {
      // calendar
      panel.add(dp);
    }
  }

}
